package com.music.auth.controller.web;

import com.music.auth.form.LoginWebBody;
import com.music.auth.form.RegisterWebBody;
import com.music.auth.service.LoginService;
import com.music.common.core.web.domain.AjaxResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * token 控制
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/auth/web")
public class TokenWebController {
    @Resource
    LoginService loginService;

    @PostMapping("login")
    public AjaxResult login(@RequestBody LoginWebBody loginWebBody) {
        return AjaxResult.success("登录成功！", loginService.login(loginWebBody));
    }

    @PostMapping("register")
    public AjaxResult register(@RequestBody RegisterWebBody registerWebBody) {
        return AjaxResult.success("注册成功！", loginService.register(registerWebBody));
    }
}
